<?php 
/**
 * 
 * 充值基类
 * @author Kerry
 * @since 2013-03-29
 * **/
class RechargeGame
{
	/**
	 * 
	 *@var $prefix 充值类前缀  
	 * 
	 * **/
	const GAME_CHARGE_PREFIX = 'Recharge';
	
	/**
	 * 
	 * @var $_options 基本配置
	 * 
	 * **/
	 private $_options = NULL;
	 
     
     public function __construct($gameId)
     {
        	$this->setOption($gameId); 	
     }
     
     /**
      * 
      * 执行支付
      * 
      * **/
     public function excute()
     {
        return $this->includePayClass($this->getOptions('payClassName'));
     }
     /**
      * 
      * 设置基本配置
      * 
      * **/
     private function setOption($gameId)
     {
         $payInfo = include 'gameRecharge.php';
         $this->_options['payClassName'] = $payInfo['mapping'][$gameId];
         $this->_options['requetUrl']    = $payInfo['config'][$this->_options['payClassName']]['requestUrl'];
         return $this;
     }
     
     /**
      * 
      * 获取配置
      * 
      * **/
     private function getOptions($key)
     {
		if(isset($this->_options[$key])){
			return $this->_options[$key];
		}
     }
     
     /**
      * 
      * 加载类
      * 
      * **/
     private function includePayClass($className)
     {
     	  $className = strtolower($className);
          include 'recharge/'.$className.".php";
          $payClass = new ReflectionClass(self::GAME_CHARGE_PREFIX.'_'.ucfirst($className));
          return $payClass->newInstance($this->_options);
     }
}